package com.yhy.wxzn.wcs.service.impl;

import com.yhy.wxzn.common.enums.WcsDeviceStatusEnums;
import com.yhy.wxzn.wcs.entity.WcsDeviceInfo;
import com.yhy.wxzn.wcs.entity.WcsDeviceLog;
import com.yhy.wxzn.wcs.mapper.WcsDeviceLogMapper;
import com.yhy.wxzn.wcs.service.IWcsDeviceInfoService;
import com.yhy.wxzn.wcs.service.IWcsDeviceLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 设备日志
 * @Author: jeecg-boot
 * @Date:   2023-10-28
 * @Version: V1.0
 */
@Service
public class WcsDeviceLogServiceImpl extends ServiceImpl<WcsDeviceLogMapper, WcsDeviceLog> implements IWcsDeviceLogService {

    @Autowired
    private IWcsDeviceInfoService wcsDeviceInfoService;

    @Override
    public void genDeviceLogInfo(WcsDeviceInfo deviceInfo, String content,int isOnline) {
        WcsDeviceLog deviceLog = new WcsDeviceLog();
        deviceLog.setDeviceCode(String.valueOf(deviceInfo.getId()));
        deviceLog.setContent(content);
        this.save(deviceLog);
        wcsDeviceInfoService.saveOrUpdate(deviceInfo);
    }

    @Override
    public void genBcrReadInfo(String deviceNo, String content) {
        WcsDeviceLog deviceLog = new WcsDeviceLog();
        deviceLog.setDeviceCode(deviceNo);
        deviceLog.setContent(content);
        this.save(deviceLog);
    }

    @Override
    public void genCoordLog(String coord, String content) {
        WcsDeviceLog deviceLog = new WcsDeviceLog();
        deviceLog.setDeviceCode(coord);
        deviceLog.setContent(content);
        this.save(deviceLog);
    }

    @Override
    public void genDeviceOperationLogInfo(WcsDeviceInfo deviceInfo, String msg) {
        WcsDeviceLog deviceLog = new WcsDeviceLog();
        deviceLog.setDeviceCode(String.valueOf(deviceInfo.getId()));
        deviceLog.setContent(msg);
        this.save(deviceLog);
    }
}
